package top.yuyufeng.mbuy.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import top.yuyufeng.mbuy.constant.ServerConstant;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author yuyufeng
 * @date 2017/4/20
 * request中获取绝对url
 */
public class URLBrokerLauncherInterceptor implements HandlerInterceptor {

    @Autowired
    private ServerConstant serverConstant;

    @Override
    public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o) throws Exception {
        httpServletRequest.setAttribute("serverApp", serverConstant.getServerApp());
        httpServletRequest.setAttribute("serverStatic", serverConstant.getServerStatic());
        httpServletRequest.setAttribute("serverFile", serverConstant.getServerFile());
        return true;
    }

    @Override
    public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception {

    }

    @Override
    public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {

    }
}
